<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/reg.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	function change(img) {
		var url = "code/img.jsp?" + new Date();
		img.src = url;
	}
</script>
<title>用户注册</title>
</head>
<body>
	<div class="main">
		<div class="mainin">
			<div class="mainin1" style="height:500px">
			<h1 style="font-size: 32px; color: #4169E1">用户注册</h1>
				<form action="UserServlet?task=reg" method="post" onsubmit="return checkAll()">
				<ul>
					<li><input
						name="username" type="text" id="username" placeholder="用户名"
						class="SearchKeyword" onblur="checkUser()"><span id="usernameMsg"></span></li>
					<li><input
						type="password" name="password" id="password" placeholder="密码"
						class="SearchKeyword" onblur="checkPwd()"><span id="passwordMsg"></span></li>
					<li><input
						type="password" id="password2" placeholder="确认密码"
						class="SearchKeyword" onblur="checkPwd2()"><span id="password2Msg"></span></li>
					<li><input
						type="text" id="code" placeholder="验证码" class="SearchKeyword" style="width:165px;"  onblur="checkCode()">
						<img src="code/img.jsp" class="code" onclick="change(this)" /><span id="codeMsg"></span></li>
					<li><input type="submit" class="tijiao" value="提交"></li>
				</ul>
				</form>
			</div>

		</div>
	</div>



	<script>
		$(function() {
			$("#username").blur(function() {
				var username = $("#username").val();
				$.ajax({
					type : "post",
					url : "UserServlet",
					data : {
						"username" : username,
						"task" : "checkName",
					},
					success : function(msg) {
						if (msg == "false") {
							
							$("#usernameMsg").html("用户名已被注册！");
							$('#usernameMsg').css("color", "red");
						} else {
							
							$("#usernameMsg").html(" ");
						}
					}
				})
			})

		})
	</script>

	<script>
		$(function mycode() {
			$("#code").blur(function() {
				var codeVal = $("#code").val();

				$.ajax({
					type : "post",
					url : "UserServlet",
					data : {
						"code" : codeVal,
						"task" : "checkCode",
					},
					success : function(msg) {
						if (msg == "false") {
							alert("验证码错误！");

						}
					}
				})
			})

		})
	</script>
</body>
</html>